package com.weiaibenpao.demo.chislim.presenter;

import com.orhanobut.logger.Logger;
import com.weiaibenpao.demo.chislim.base.BasePresenter;
import com.weiaibenpao.demo.chislim.bean.LikerListBean;
import com.weiaibenpao.demo.chislim.retrofit.RetrofitUtils;
import com.weiaibenpao.demo.chislim.retrofit.rx.NetWorkTransformer;
import com.weiaibenpao.demo.chislim.retrofit.rx.SimpleObserver;
import com.weiaibenpao.demo.chislim.utils.Constant;
import com.weiaibenpao.demo.chislim.view.LikerListView;

/**
 * Created by Administrator on 2018/1/5.
 */

public class LikerListPresenter extends BasePresenter<LikerListView> {

    public void getLikerList(int momentId,int page){
        Logger.e("getLikerList----->");
        RetrofitUtils
                .getAPIService()
                .getLikerList(momentId,page, Constant.DEFAULT_PAGE_SIZE)
                .compose(new NetWorkTransformer<LikerListBean>())
                .subscribe(new SimpleObserver<LikerListBean>(mCompositeDisposable) {
                    @Override
                    public void call(LikerListBean bean) {
                        getView().onGetLikerListSuccess(bean);
                    }

                    @Override
                    public void showErrorMsg(String message) {
                        if(getView() != null)
                            getView().onGetLikerListFailed(message);
                    }
                });
    }

}
